import FileSaver from "file-saver";
import XLSX from "xlsx";

export function downLoadAsExcel(name){
    var wb = XLSX.utils.table_to_book(name);
    var wbout = XLSX.write(wb, {
        bookType: "xlsx",
        bookSST: true,
        type: "array"
    });
    try {
        FileSaver.saveAs(
        new Blob([wbout], { type: "application/octet-stream" }),
        "表格"+ ".xlsx" //  name+'.xlsx'表示导出的excel表格名字
        );
    } catch (e) {
        if (typeof console !== "undefined") console.log(e, wbout);
    }
    return wbout;
}
